﻿/********************************************************************
	created:	2011-8-14   16:05
	author:		Lifan Su
	
	purpose:	Interface of CRC-64 functions.
*********************************************************************/

#ifndef CRC64_H
#define CRC64_H

#include "crypt_hash_common.h"

#ifdef __cplusplus
extern "C" {
#endif

    //  data only
    struct CRC64_d {
        uint64_t    hash[1];
    };

    //  stream with statue
    struct CRC64_c {
        uint64_t    hash[1];

        uint64_t    length;
        uint8_t     append;
    };


    //  from big-endian, as hex print in hashcalc
    CRYPT_HASH_PREFIX void CRYPT_HASH_API crc64_d_read(struct CRC64_d *, const void *);

    //  to big-endian, as hex print in hashcalc
    CRYPT_HASH_PREFIX void CRYPT_HASH_API crc64_d_write(void *, const struct CRC64_d *);

    //  print, at least 17 char shall be provided
    CRYPT_HASH_PREFIX void CRYPT_HASH_API crc64_d_print(char *, const struct CRC64_d *);
    CRYPT_HASH_PREFIX void CRYPT_HASH_API crc64_d_printw(wchar_t *, const struct CRC64_d *);

    //  comp
    CRYPT_HASH_PREFIX uint8_t CRYPT_HASH_API crc64_d_less(const struct CRC64_d *, const struct CRC64_d *);
    CRYPT_HASH_PREFIX uint8_t CRYPT_HASH_API crc64_d_eq(const struct CRC64_d *, const struct CRC64_d *);

    //  convert
    CRYPT_HASH_PREFIX void CRYPT_HASH_API crc64_cvt(struct CRC64_d *, const struct CRC64_c *);

    //  init
    CRYPT_HASH_PREFIX void CRYPT_HASH_API crc64_c_init(struct CRC64_c *);

    //  append
    CRYPT_HASH_PREFIX void CRYPT_HASH_API crc64_c_append(struct CRC64_c *, const void *, uint64_t);

    //  close
    CRYPT_HASH_PREFIX void CRYPT_HASH_API crc64_c_close(struct CRC64_c *);


#ifdef __cplusplus
}
#endif

#endif // CRC64_H